home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Dev / ACE / include / strings.h / text0000.txt < prev   
Encoding:
Text File  |  1994-10-22  |  2.1 KB  |  75 lines

  1. Rem *** LCASE$ (function)
  2. Rem ***
  3. Rem *** FUNCTION:
  4. Rem *** Simulates the LCASE$ function hard-wired into some other
  5. Rem *** BASICs. Takes a string as input, and returns that string
  6. Rem *** with all uppercase letters converted to lowercase.
  7. Rem ***
  8. Rem *** REVISION HISTORY:
  9. Rem *** Version 1.0: Roland Acton (xracton@ccvax.fullerton.edu)
  10. Rem ***
  11. Rem *** BUGS:
  12. Rem *** Can only handle strings up to MAXSTRINGLEN.
  13.  
  14. SUB LCASE$(A$)
  15.   Longint STEPPER
  16.   String B$
  17.   B$=A$
  18.   STEPPER=@B$
  19. Rem *** Not perfectly portable, but everybody uses ASCII these days,
  20. Rem *** right?
  21.   Repeat
  22.     If Peek(STEPPER)>=65 And Peek(STEPPER)<=90 Then
  23.       Poke STEPPER,Peek(STEPPER)+32
  24.     End If
  25.     ++STEPPER
  26.   Until Peek(STEPPER)=0
  27.   LCASE$=B$
  28. END SUB
  29.  
  30.  
  31.  
  32. Rem *** MIDCOM$ (function)
  33. Rem ***
  34. Rem *** FUNCTION:
  35. Rem *** Simulates the MID$ command. A$, starting at position B%, has
  36. Rem *** its contents replaced by C$. This is done until either D%
  37. Rem *** characters have been replaced, or the end of either A$ or C$
  38. Rem *** has been reached. This is consistent with the way it is
  39. Rem *** implemented in AmigaBASIC (though AmigaBASIC uses a
  40. Rem *** different syntax). The contents of A$ are then returned to
  41. Rem *** the calling program.
  42. Rem *** For example, if NAME$ contains the string "Goodbye",
  43. Rem ***
  44. Rem *** NAGISA$=MIDCOM$(NAME$,2,"Iczer",1)
  45. Rem ***
  46. Rem *** will make NAGISA$ contain the string "GIodbye". NAME$ will
  47. Rem *** be unaffected. Thus, if you actually wanted to alter NAME$
  48. Rem *** (as the "real" MID$ command would do) you would have to use
  49. Rem ***
  50. Rem *** NAME$=MIDCOM$(NAME$,2,"Iczer",1)
  51. Rem ***
  52. Rem *** Note that since ACE does not allow function overloading, all
  53. Rem *** four parameters are required. Pass D% a very high number if
  54. Rem *** you want it ignored.
  55. Rem ***
  56. Rem *** REVISION HISTORY:
  57. Rem *** Version 1.0: Roland Acton (xracton@ccvax.fullerton.edu)
  58. Rem ***
  59. Rem *** BUGS:
  60. Rem *** None known.
  61.  
  62. SUB MIDCOM$(A$,B%,C$,D%)
  63.   Longint STEPA, STEPC
  64.   STEPA=@A$+B%-1
  65.   STEPC=@C$
  66.   While Peek(STEPA)<>0 And Peek(STEPC)<>0 And D%>0
  67.     Poke STEPA,Peek(STEPC)
  68.     ++STEPA
  69.     ++STEPC
  70.     --D%
  71.   Wend
  72.   MIDCOM$=A$
  73. END SUB
  74.  
  75.